home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
I-Z
/
OnScreen MDEF.sit
/
MDEF
/
MDEF.main.c
next >
Wrap
Text File
|
1993-03-22
|
3KB
|
102 lines
/******************** MDEF.main.c *********************/
#include <SetUpA4.h>
#define kMenuIconWidth 24
#define kItemHeight 20
#define kScrollHeight 7
#define kSystemMDEFID 0
/************************* PROC PTR for an MDEF ***************************/
typedef pascal void (*MDEFProcPtr) (short message, MenuHandle theMenu, RectPtr menuRect,
Point hitPoint,short *whichItem);
/***************************declarations***********************************/
pascal void main (short message, MenuHandle theMenu, RectPtr menuRect,
Point hitPoint,short *whichItem);
/****************************definitions***********************************/
void JumpToSystemMDEF(short message, MenuHandle theMenu, RectPtr menuRect,
Point hitPoint,short *whichItem) {
Handle MDEFHandle;
MDEFHandle = GetResource ('MDEF', kSystemMDEFID);
if (MDEFHandle == nil)
return;
else
{
char saveState;
saveState = HGetState(MDEFHandle);
HLock (MDEFHandle);
/* The next line actually jumps to the code segment */
(* (MDEFProcPtr) (*MDEFHandle)) (message,theMenu,menuRect,hitPoint,whichItem);
HSetState(MDEFHandle,saveState);
}
}
/*****************************************************************************/
/* Main */
/*****************************************************************************/
/* This routine just gets the hitpoint from the Menu Manager then adjusts it */
/* so that the MDEF either gets shown entirely on the screen or the largest */
/* portion gets shown on the screen. This makes the MDEF 100% compatible. */
/*****************************************************************************/
pascal void main (short message, MenuHandle theMenu, RectPtr menuRect,
Point hitPoint,short *whichItem) {
GrafPtr Screen;
short itemCount, mouseItem;
Boolean MenuScrolls = FALSE;
RememberA0();
SetUpA4();
HLock(theMenu);
itemCount = CountMItems( theMenu );
switch (message) {
default:
JumpToSystemMDEF(message,theMenu,menuRect,hitPoint,whichItem);
break;
/* Calc the Rect Size */
case mPopUpMsg: {
GrafPtr theScreen;
RectPtr screenRect;
short height = kItemHeight*itemCount;
GetWMgrPort( &theScreen );
/* Get the screen Rect */
screenRect = &(*theScreen).portRect;
/* Adjust the top of the menu */
if (hitPoint.h + height > screenRect->bottom ) {
hitPoint.h = (screenRect->bottom) - height;
if (hitPoint.h + height > screenRect->bottom - 24 && itemCount == 2) {
hitPoint.h = hitPoint.h - (height/2);
}/*if*/
}/*if*/
/* Make sure that the menu does not pop up above the screen.*/
if (hitPoint.h < screenRect->top) hitPoint.h = screenRect->top + 5;
/* Call the System MDEF */
JumpToSystemMDEF(message,theMenu,menuRect,hitPoint,whichItem);
break; }/* mPopUpMsg */
}/*switch*/
HUnlock(theMenu);
CleanUp:
/*Restore A4*/
RestoreA4();
}/*main*/